package com.Pratice;

import java.math.BigInteger;
import java.util.Scanner;

public class PREV57 {
	public static void main(String[] args) {
		long res = 0;
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		int[] pre = new int[str.length()];
		int[] last = new int[26];
		for(int i = 0;i < 26; i++) last[i] = -1;
		for(int i = 0;i < str.length();i++)
		{
		      int x = str.charAt(i) - 'a';
		      pre[i] = last[x];
		      last[x] = i;
		}
		for(int i = 0;i < str.length();i++)
		{
			res += (i - pre[i])*(str.length() - i);
		}
		System.out.println(res);
	}
}
